#!/bin/bash 
set -e

TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage3}
SRC=${SRC:-/sources}

name=e2fsprogs
version=1.46.1

rm -rf $TMP
mkdir -p $TMP $LOG

tar xf $SRC/$name-$version.tar.gz -C $TMP

{ time \
   {

    cd $TMP/$name-$version
    
    mkdir -v build
    cd       build

	../configure --prefix=/usr           \
				 --bindir=/bin           \
				 --with-root-prefix=""   \
				 --enable-elf-shlibs     \
				 --disable-libblkid      \
				 --disable-libuuid       \
				 --disable-uuidd         \
				 --disable-fsck
    
    make
    
    make install
    
	rm -fv /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a
		
	gunzip -v /usr/share/info/libext2fs.info.gz
	install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info

	makeinfo -o      doc/com_err.info ../lib/et/com_err.texinfo
	install -v -m644 doc/com_err.info /usr/share/info
	install-info --dir-file=/usr/share/info/dir /usr/share/info/com_err.info

    }
} 2>&1 | tee $name.log
    
[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
